import 'package:hockey/jzx_apps.dart';
import 'package:hockey/jzx_models.dart';
import 'package:hockey/services/jzx_config.dart';

class JzxFollowedListController extends GetxController {
  final itmes = <JzxFollowData>[].obs;

  @override
  void onInit() async {
    super.onInit();

    fetchData();
  }

  fetchData() async {
    showLoading();
    final res =
        await JzxNetRepository.client.followList({'limit': 50, 'page': 1});
    itmes.value = res
        .where((element) =>
            !JzxConfigService.to.blockList.contains(element.userId))
        .toList();
    hideLoading();
  }

  void removeUser(int index) async {
    final item = itmes[index];
    showLoading();
    await JzxNetRepository.client.removeFollow({'followUserId': item.userId});
    hideLoading();
    itmes.removeAt(index);
    JzxConfigService.to.updateFollows(item.userId);
    showMessage('Successfully');
  }
}
